package com.weilan.blog.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.weilan.blog.admin.mapper.BlogSubjectMapper;
import com.weilan.blog.admin.service.BlogSubjectService;
import com.weilan.blog.admin.vo.BlogSubjectVO;
import com.weilan.blog.base.enums.EStatus;
import com.weilan.blog.base.serviceImpl.SuperServiceImpl;
import com.weilan.blog.common.global.SQLConf;
import com.weilan.blog.admin.entity.BlogSubject;
import com.weilan.blog.utils.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: 孙 峰
 * @time: 2020/9/27 23:57
 */
@Service
public class BlogSubjectServiceImpl extends SuperServiceImpl<BlogSubjectMapper, BlogSubject> implements BlogSubjectService {


    @Override
    public IPage<BlogSubject> getPageList(BlogSubjectVO blogSubjectVO) {
        QueryWrapper<BlogSubject> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(blogSubjectVO.getKeyword()) && !StringUtils.isEmpty(blogSubjectVO.getKeyword().trim())) {
            queryWrapper.like(SQLConf.CATEGORY_NAME, blogSubjectVO.getKeyword().trim());
        }
        Page<BlogSubject> page = new Page<>();
        page.setCurrent(blogSubjectVO.getCurrentPage());
        page.setSize(blogSubjectVO.getPageSize());
        queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
        queryWrapper.orderByDesc(SQLConf.SORT);
        return page(page,queryWrapper);
    }

    @Override
    public String addSubject(BlogSubjectVO blogSubjectVO) {
        return null;
    }

    @Override
    public String editSubject(BlogSubjectVO blogSubjectVO) {
        return null;
    }

    @Override
    public String deleteBatchSubject(List<BlogSubjectVO> blogSubjectVOList) {
        return null;
    }
}
